package com.ymttest.database.sqlwapper.sqdistributor;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqdistributor.DistributionAgencySubDistributorCommisionRate;

public class DistributionAgencySubDistributorCommisionRateWrapper {
	
	SqlManager manager;

	public DistributionAgencySubDistributorCommisionRateWrapper() {
		manager = new SqlManager("sqdistributor");
	}

	@SuppressWarnings("unchecked")
	public DistributionAgencySubDistributorCommisionRate selectByPrimaryKey(Long id) {

		DistributionAgencySubDistributorCommisionRate distributionAgencySubDistributorCommisionRate = null;
		List<DistributionAgencySubDistributorCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.DistributionAgencySubDistributorCommisionRateMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			distributionAgencySubDistributorCommisionRate = result.get(0);
		}

		return distributionAgencySubDistributorCommisionRate;
	}
	
	@SuppressWarnings("unchecked")
	public List<DistributionAgencySubDistributorCommisionRate> selectByConfigId(Long id) {

		List<DistributionAgencySubDistributorCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.DistributionAgencySubDistributorCommisionRateMapper.selectByConfigId",
						id);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public DistributionAgencySubDistributorCommisionRate selectByConfigIdAndLevelIndex(Long configId, Integer levelIndex) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("distribution_agency_sub_distributor_config_id", configId);
		map.put("distributor_level_index", levelIndex);
		
		DistributionAgencySubDistributorCommisionRate distributionAgencySubDistributorCommisionRate = null;
		
		List<DistributionAgencySubDistributorCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.DistributionAgencySubDistributorCommisionRateMapper.selectByConfigIdAndLevelIndex",
						map);
		manager.commit();

		if (result.size() > 0) {
			distributionAgencySubDistributorCommisionRate = result.get(0);
		}

		return distributionAgencySubDistributorCommisionRate;
	}
	
	public static void main(String[] args) {
		
		DistributionAgencySubDistributorCommisionRateWrapper test = new DistributionAgencySubDistributorCommisionRateWrapper();

		System.out.println(test.selectByConfigIdAndLevelIndex(42L, 0).getDistribution_agency_sub_distributor_config_id());
	}
}
